package com.walker.taogong.bll.impl;


import java.util.List;

import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.walker.taogong.bll.TaskBll;
import com.walker.taogong.dal.TaskDal;
import com.walker.taogong.datamodel.Task;

public class TaskBllImpl implements TaskBll
{

    
    /** Logger. */
    private static Logger log = LoggerFactory.getLogger(UserBllImpl.class);
    
    
    /************************ DAL 服务引用 *******************************************/
    
    private TaskDal taskDal;
    
    public void setTaskDal(TaskDal taskDal)
    {
        this.taskDal = taskDal;
    }
    
    
    @Override
    public boolean postTask(Task task)
    {
       taskDal.saveTask(task);
       return true;
    }
    
    /**
     * 取得反馈最多的10个任务
     */
    @Override
    public List<Task> getTopTasks()
    {
        return taskDal.getAllTasks();
    }


    /**
     * 取得最新发布的10个任务
     */
    @Override
    public List<Task> getNewestTasks()
    {
        return taskDal.getAllTasks();
    }
    
    @Override
    public Task getTaskInfo(int id)
    {
        return taskDal.getTaskById(id);
    }
    
    /*************************启动組件**********************************************/
    /**
     * 组件启动初期化
     */
    protected void activate(ComponentContext cc)
    {
        log.info("{} is starting!", cc.getProperties().get("name") );

    }







}
